/**
 * 
 */
package com.asdf.tests;

import java.util.Date;

import com.asdf.external.DBUsageDetails;

/**
 * @author ilia
 *
 */
public class SimpleUsage
{
	String 	userId;
	String 	airportId;
	Date 	date;
	int 	duration;

	public SimpleUsage(String airportId, String userId, Date date, int duration)
	{
		this.airportId = airportId;
		this.userId = userId;
		this.date = date;
		this.duration = duration;
	}

	public SimpleUsage(SimpleUsage u) {
		this(u.airportId, u.userId, u.date, u.duration);
	}

	public SimpleUsage(DBUsageDetails u) {
		this(u.getAirportId(), u.getUserId( ), u.getDate( ), u.getDuration( ));
	}

	/*
	boolean equals(DBUsageDetails usage) {
		return  userId.equalsIgnoreCase( usage.getUserId()) &&
				airportId.equalsIgnoreCase( usage.getAirportId()) &&
				date.equals( usage.getDate() ) &&
				duration == usage.getDuration();
	}
	*/

	public boolean equals(Object o) {
		if (o==null) return false;
		if (o instanceof SimpleUsage) {
			SimpleUsage u = (SimpleUsage) o;
			return  userId.equalsIgnoreCase( u.userId) &&
					airportId.equalsIgnoreCase( u.airportId) &&
					date.equals( u.date ) &&
					duration == u.duration;
		}
		if (o instanceof DBUsageDetails)
			return equals(new SimpleUsage((DBUsageDetails)o));
			
		return false;
	}
}
